package com.example.studentims.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

import java.nio.file.Paths;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 获取当前 .jar 所在目录，并拼接 photos 子目录
        String photoDir = Paths.get(System.getProperty("user.dir"), "photos").toUri().toString();

        // 映射 /photos/** 到 {当前目录}/photos/
        registry.addResourceHandler("/photos/**")
                .addResourceLocations(photoDir);
    }
}
